﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 索引函数
{
    public partial class Form1 : Form
    {
        Contact c1;
        public Form1()
        {
            InitializeComponent();
            c1 = new Contact("胡");
            c1["办公"] = "13547226541";
            c1["手机"] = "18325426541";
            c1["传真"] = "135-722-541";
            textBox1.Text = c1.Name;
            comboBox1.SelectedItem = c1;
            
            try
            {
                comboBox1.SelectedIndex =0; 
            }
            catch (ArgumentOutOfRangeException e)
            {
                Console.WriteLine(e.Message);
            }
        }
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            textBox2.Text = c1[comboBox1.Text];
        }
    }
}